package com.xuyh.pdf.utils;

import cn.hutool.core.io.FileUtil;
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;
import net.coobird.thumbnailator.Thumbnails;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;

/**
 * @author xuyh
 * @email xuyh0817@foxmail.com
 * @date 2023/7/10 13:12
 * @description 缩放图片
 */
public class ScalePhoto {
    public static void main(String[] args) throws IOException {
        byte[] bytes = FileUtil.readBytes("C:\\xuyh\\3.jpg");
        ByteOutputStream outputStream = new ByteOutputStream();
        Thumbnails.of(new ByteArrayInputStream(bytes))
                .scale(1.2)
                .outputQuality(1)
                .toOutputStream(outputStream);

        FileUtil.writeBytes(outputStream.getBytes(),new File("c:\\xuyh\\4.jpg"));
    }
}
